package cn.vcjf.weapp.api.active.controller;


import org.springframework.web.bind.annotation.RequestMapping;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.ResponseBody;
import cn.vcjf.weapp.common.web.TableResult;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import cn.vcjf.weapp.api.active.entity.GoodsSetmealDetail;
import cn.vcjf.weapp.api.active.service.GoodsSetmealDetailService;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  套餐详情
 * </p>
 *
 * @author zhengzihang
 * @since 2018-09-28
 */
@Controller
@RequestMapping("/active/goodsSetmealDetail")
public class GoodsSetmealDetailController {
     @Resource
     private GoodsSetmealDetailService  goodsSetmealDetailService;

     @RequestMapping("/addGoodsSetmealDetail")
     @ResponseBody
     public TableResult addGoodsSetmealDetail(GoodsSetmealDetail goodsSetmealDetail){
         goodsSetmealDetail.preInsert();
         boolean b = goodsSetmealDetailService.insert(goodsSetmealDetail);
         return TableResult.Result(b);
     }

     @RequestMapping("/updateGoodsSetmealDetail")
     @ResponseBody
     public TableResult updateGoodsSetmealDetail(GoodsSetmealDetail goodsSetmealDetail){
         goodsSetmealDetail.preUpdate();
         boolean b = goodsSetmealDetailService.updateById(goodsSetmealDetail);
         return TableResult.Result(b);
     }

     @RequestMapping("/findGoodsSetmealDetailOne")
     @ResponseBody
     public TableResult findGoodsSetmealDetailOne(GoodsSetmealDetail goodsSetmealDetail){

        EntityWrapper<GoodsSetmealDetail> wrapper = goodsSetmealDetail.getQueryWrapper();
        //Todo

        GoodsSetmealDetail result = goodsSetmealDetailService.selectOne(wrapper);

		return TableResult.OKResult(result);
     }

     @RequestMapping("/findGoodsSetmealDetailList")
     @ResponseBody
     public TableResult findGoodsSetmealDetailList(GoodsSetmealDetail goodsSetmealDetail){

        EntityWrapper<GoodsSetmealDetail> wrapper = goodsSetmealDetail.getQueryWrapper();
        //Todo

        Page<GoodsSetmealDetail> page = goodsSetmealDetail.getPageInfo();

        page = goodsSetmealDetailService.selectPage(page,wrapper);

		return TableResult.OKResult(page);

     }

     @RequestMapping("/deleteGoodsSetmealDetail")
     @ResponseBody
     public TableResult deleteGoodsSetmealDetail(GoodsSetmealDetail goodsSetmealDetail){
        goodsSetmealDetail.preUpdate();
        boolean b = goodsSetmealDetailService.deleteById(goodsSetmealDetail.getId());
        return TableResult.Result(b);
     }

}
